﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using HigLabo.Net.Extensions;
using Newtonsoft.Json.Linq;

namespace HigLabo.Net.Twitter
{
    /// <summary>
    /// 
    /// </summary>
    public class Suggestion : ResponseObject
    {
        private String _Name = null;
        private String _Slug = null;
        private Int32 _Size = 0;
        private UserCollection _Users = null;
        /// <summary>
        /// 
        /// </summary>
        public String Name
        {
            get { return this._Name; }
            set { this._Name = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public String Slug
        {
            get { return this._Slug; }
            set { this._Slug = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public Int32 Size
        {
            get { return this._Size; }
            set { this._Size = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public UserCollection Users
        {
            get { return this._Users; }
            set { this._Users = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public Suggestion(String jsonText)
        {
            this.SetProperty(jsonText);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public override void SetProperty(string jsonText)
        {
            var d = this.SetData(jsonText);
            
            this.Name = d.ToString("name");
            this.Slug = d.ToString("slug");
            this.Size = d.ToInt32("size") ?? this.Size;

            this.Users = new UserCollection(d.ToString("users"));
        }
    }
}
